var e = getApp();

Page({
    data: {
        name: "",
        mobile: "",
        goods_list: [],
        goods_id: 0,
        shopkeeper: 0
    },
    onLoad: function(e) {
        e.shopkeeper && 1 == e.shopkeeper ? (this.setData({
            shopkeeper: 1
        }), wx.setNavigationBarTitle({
            title: "店主信息"
        })) : this.getApplyInfo();
    },
    getApplyInfo: function() {
        var t = this, o = e.getNetAddresss("plugin.owner-order-import.frontend.modules.owner.controllers.register.index");
        e._postNetWork({
            url: o,
            success: function(o) {
                var n = o.data;
                if (1 != n.result) return e.tips(n.msg);
                t.setData({
                    goods_list: n.data.goods_list,
                    name: n.data.owner.name,
                    mobile: n.data.owner.mobile
                });
            },
            fail: function(e) {
                console.log(e.msg);
            }
        });
    },
    setGoodsId: function(e) {
        var t = e.currentTarget.dataset.id;
        this.setData({
            goods_id: t
        });
    },
    sendApply: function() {
        var t = this;
        if (e._isTextEmpty(this.data.name)) return e.tips("请输入申请姓名");
        if (e._isTextEmpty(this.data.mobile)) return e.tips("请输入手机号");
        if (e._isMoblie(this.data.mobile)) return e.tips("请输入正确手机号");
        var o = e.getNetAddresss("plugin.owner-order-import.frontend.modules.owner.controllers.perfect.index");
        if (1 != this.data.shopkeeper) {
            if (this.data.goods_id <= 0) return e.tips("请选择商品");
            o = e.getNetAddresss("plugin.owner-order-import.frontend.modules.owner.controllers.apply.index");
        }
        e._postNetWork({
            url: o,
            data: {
                name: this.data.name,
                mobile: this.data.mobile
            },
            success: function(o) {
                var n = o.data;
                if (1 != n.result) return e.tips(n.msg);
                if (1 != t.data.shopkeeper) wx.redirectTo({
                    url: "/packageA/detail_v2/detail_v2?id=" + t.data.goods_id
                }); else {
                    var s = getCurrentPages();
                    s[s.length - 2].getListData(), wx.navigateBack();
                }
            },
            fail: function(e) {
                console.log(e.msg);
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});